package com.srxz.mobilepharmacy.util;

import com.alibaba.fastjson.JSON;
import com.srxz.mobilepharmacy.entity.UserInfoPK;
import lombok.extern.slf4j.Slf4j;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @ClassName: LogTool
 * @author: wgchao
 * @createTime: 2019/1/10 10:38 AM
 * @Description: 操作日志记录
 */
@Slf4j
public class LogTool {
    private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    /**
     *
     * @param typ 1:发药 2：盘点
     * @param bs 操作唯一标示 - 时间
     * @param user 操作人
     * @param message 操作信息
     * @param other 其他信息
     */
    public static void pdLog(int typ, long bs, UserInfoPK user, Object message, String other){
        if(typ == 2){
            StringBuilder logsb = new StringBuilder();
            logsb.append("库存盘点"+bs);
            logsb.append(" - "+JSON.toJSONString(user));
            logsb.append("\t"+ JSON.toJSONString(message));
            logsb.append("\t"+other);
            log.info(logsb.toString());
        }
        if(typ == 1){
            StringBuilder logsb = new StringBuilder();
            logsb.append("药房发药"+bs);
            logsb.append(" - "+JSON.toJSONString(user));
            logsb.append("\t"+ JSON.toJSONString(message));
            logsb.append("\t"+other);
            log.info(logsb.toString());
        }
    }

    /**
     * 操作结果记录
     * @param bs 操作唯一标示 与pdLog对应
     * @param res 操作结果
     */
    public static void resLog(int typ, long bs, String res){
        if(typ == 2)
            log.info("库存盘点"+bs+" - "+res);
        if(typ == 1)
            log.info("药房发药"+bs+" - "+res);
    }


}
